import { Spin } from 'antd'
import { connect } from 'umi';
import React, { useEffect } from 'react';
import LoadingIcon from '@/components/LoadingIcon'
import SaleWrapper from '../SaleWrapper'

const preSale = props => {
  const { dispatch, dealData, params, tab, tabKey, loading,rentMonitor } = props;

  useEffect(() => {
    if (tab === tabKey) {
      setTimeout(() => {
        dispatch({
          type: 'rentMonitor/fetchCommerBuildData',
          payload: 'rent'
        });
      }, 300)
    }
  }, [tabKey])

  return (
    <>
      <Spin spinning={loading} indicator={LoadingIcon} size="large">
        <SaleWrapper modelData={rentMonitor} dataRow={dealData} chartType="租赁" params={params} dimension="new" unmountSign='1' nameSpace='rentMonitor'/>
      </Spin>
    </>
  );
}

export default connect(({ rentMonitor, loading }) => ({
  rentMonitor,
  dealData: rentMonitor.dealData,
  tabKey: rentMonitor.tabKey,
  loading: loading.models.rentMonitor,
}))(preSale);
